package 牛客_面试必刷.Month07.day10;

public class 判断是不是平衡二叉树 {
    public int height(TreeNode root){
        if(root == null) return 0;
        return Math.max(height(root.left) + 1,height(root.right) + 1);
    }

    public boolean IsBalanced_Solution(TreeNode root) {
        if(root == null) return true;
        int left = height(root.left);
        int right = height(root.right);
        if(Math.abs(left - right) > 1) return false;
        return true;
    }
}
